<?php

namespace app\auth\service;

use app\common\models\DictionaryModel;

class DictionaryService extends BaseService
{
    protected $model;
    public function __construct()
    {
        $this->model = new DictionaryModel();
    }

    public function getData($params) {
        $condition = $this->getCondition($params);
        $count = $this->model->where($condition)->count();

        $data = $this->model->where($condition)->order('id desc')->select();
        return ['code' => $this->successCode,'msg' => $this->successMsg, 'data' => $data,'count' => $count];
    }


    private function getCondition($params) {
        $condition = $this->initCondition();

        if (!empty($params['keyword'])) {
            $condition[] = ['type', 'like' , '%'. $params['keyword'] .'%'];
        }

        return $condition;
    }


}